package ali;

import java.io.*;


public class _798_差分矩阵_二维 {
    /*
     * 二维差分和一维思路一样 就是公式不一样 画图画图画图
     */
    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] str1 = bf.readLine().split(" ");

        int n = Integer.parseInt(str1[0]);
        int m = Integer.parseInt(str1[1]);
        int q = Integer.parseInt(str1[2]);
        int N = 1010;
        int[][] a = new int[N][N];
        int[][] b = new int[N][N];

        for (int i = 1; i <= n; i++) {
            String[] str2 = bf.readLine().split(" ");
            for (int j = 1; j <= m; j++) {
                a[i][j] = Integer.parseInt(str2[j - 1]);
                //初始化差分数组
                insert(b, i, j, i, j, a[i][j]);
            }
        }

        while (q-- > 0) {
            String[] str3 = bf.readLine().split(" ");
            int x1 = Integer.parseInt(str3[0]);
            int y1 = Integer.parseInt(str3[1]);
            int x2 = Integer.parseInt(str3[2]);
            int y2 = Integer.parseInt(str3[3]);
            int k = Integer.parseInt(str3[4]);
            insert(b, x1, y1, x2, y2, k);
        }

        //数组b的前缀和就是结果
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                b[i][j] += b[i][j - 1] + b[i - 1][j] - b[i - 1][j - 1];
                bw.write(b[i][j] + " ");
            }
            bw.write("\n");
        }
        bw.flush();
        bf.close();
        bw.close();

    }

    //对差分数组进行操作 画图 公式很容易理解
    public static void insert(int[][] b, int x1, int y1, int x2, int y2, int k) {
        b[x1][y1] += k;
        b[x2 + 1][y1] -= k;
        b[x1][y2 + 1] -= k;
        b[x2 + 1][y2 + 1] += k;
    }
}

